<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yike <956606168@qq.com>
 * @copyright 2017 yikejin all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */
use think\Cache;
//------------------------
// 公共函数
//-------------------------
/**
 * 获取地区名称
 * @param $id
 * @return string
 */
function getRegionName($areaCode){
    static $areaList;
    if (!$areaCode) {
        return '';
    }
    if (empty($areaList)) {

        $areaList = Cache::get('areaList');
    }
    if (!isset($areaList[$areaCode])) {

        $name = model('region')->where(['areaCode' => $areaCode])->value('areaName');

        if (!$areaCode) {
            return '';
        }
        $areaList[$areaCode] = $name;

        Cache::set('areaList', $areaList);
    }
    return $areaList[$areaCode];
}
/**
 * 获取业务名称
 * @param $id
 * @return string
 */
function getBisName($id)
{
    static $bisNameList;
    if (!$id) {
        return '';
    }
    if (empty($bisNameList)) {

        $bisNameList = Cache::get('bisNameList');
    }
    if (!isset($branchNameList[$id])) {

        $name = model('businessList')->where(['id' => $id])->value('name');

        if (!$id) {
            return '';
        }
        $bisNameList[$id] = $name;

        Cache::set('bisNameList', $bisNameList);
    }
    return $bisNameList[$id];
}
